package com.hzqy.persistence.dao.activity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.hzqy.persistence.dao.core.PersistenceDao;
import com.hzqy.web.vo.activity.ActivityVoteUserVo;;

@Repository
public class ActivityVoteDao extends PersistenceDao<ActivityVoteUserVo, Integer> {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	public int insertVoteUser(ActivityVoteUserVo voteVo) {
		return getSqlSession().insert(this.getNamespace() +"insertVoteUser", voteVo);
	}
	public int updateGroupVoteNum(ActivityVoteUserVo voteVo) {
		int flag=0;
		int insertflag=getSqlSession().insert(this.getNamespace() +"insertVoteUser", voteVo);
		if(insertflag>0){
			flag=1;
			int updateflag=getSqlSession().update(this.getNamespace() +"updateGroupVoteNum", voteVo);
			if(updateflag==0){
				LOG.error("票数更新异常用户:"+voteVo.getF_avu_serverid()+" 投票数:"+voteVo.getF_avu_votenum());
			}
		} else {
			LOG.error("票数更新入流水表异常用户:"+voteVo.getF_avu_serverid()+" 投票数:"+voteVo.getF_avu_votenum());
		}
		return flag;
	}
	
	public List<ActivityVoteUserVo> selectVote(ActivityVoteUserVo voteVo) {
		List<ActivityVoteUserVo> voteVoList = getSqlSession().selectList(this.getNamespace() + "selectVote",voteVo);
		return voteVoList;
	}
	
	public List<ActivityVoteUserVo> selectVoteGroupByCatalogId(ActivityVoteUserVo voteVo) {
		List<ActivityVoteUserVo> voteVoList = getSqlSession().selectList(this.getNamespace() + "selectVoteGroupByCatalogId",voteVo);
		return voteVoList;
	}

	public int selectTicketNum(Map map) {
		int flag=0; 
		Object obj= getSqlSession().selectOne(this.getNamespace() +"selectTicketNum", map);
		if(obj!=null){
			flag=(Integer) obj;
		}
		return flag;
	}

	public int prvingContentDate(int f_avu_contentid) {
		int flag=0; 
		Object obj= getSqlSession().selectOne(this.getNamespace() +"prvingContentDate", f_avu_contentid);
		if(obj!=null){
			flag=(Integer) obj;
		}
		return flag;
	}
	public List<ActivityVoteUserVo> selectUserOrderVoteNumList(HashMap<String, String> map) {
		List<ActivityVoteUserVo> voteVoList = getSqlSession().selectList(this.getNamespace() + "selectUserOrderVoteNumList",map);
		return voteVoList;
	}
}
